<template>
  <a-input-number
    v-model="num"
    :min="0"
    :formatter="value => `${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, ',')"
    :parser="value => `${value}`.replace(/\$\s?|(,*)/g, '')"
    :precision="2"
    v-bind="$attrs"
    @change="$emit('input', num)"
    @blur="blur"
  />
</template>
<script>
export default {
  name: 'mInputNumber',
  props: ['value'],
  data() {
    return {
      num: ''
    }
  },
  mounted() {
    this.num = this.value
  },
  watch: {
    value(v) {
      this.num = v
    }
  },
  methods:{
    blur(v){
      this.$emit('blur',this.num)
    }
  }
}
</script>
<style lang="css" scoped></style>
